package com.woniuxy.controller;

import com.woniuxy.entity.dto.DepartmentDTO;
import com.woniuxy.entity.dto.NormalOrderDTO;
import com.woniuxy.service.OrderService;
import com.woniuxy.service.impl.OrderServiceImpl;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @Resource
    private OrderServiceImpl orderServiceImpl;

    @PostMapping("/queryCustomerOrder")
    public ResponseData<?> queryCustomerOrder(@RequestBody PageData<NormalOrderDTO> pageData) {
        return orderService.queryCustomerOrder(pageData);
    }

    @PostMapping("/queryUserOrder")
    public ResponseData<?> queryUserOrder(@RequestBody PageData<NormalOrderDTO> pageData) {
        return orderService.queryUserOrder(pageData);
    }

    @GetMapping( "/queryBasicDetail/{id}")
    public ResponseData<?> queryBasicDetail(@PathVariable("id") String id) {
        return orderService.queryBasicDetail(id);
    }

    @GetMapping( "/querySendDetail/{id}")
    public ResponseData<?> querySendDetail(@PathVariable("id") String id) {
        return orderService.querySendDetail(id);
    }

    @GetMapping( "/queryDeliveryDetail/{id}")
    public ResponseData<?> queryDeliveryDetail(@PathVariable("id") String id) {
        return orderService.queryDeliveryDetail(id);
    }

    @GetMapping( "/queryGoodsDetail/{id}")
    public ResponseData<?> queryGoodsDetail(@PathVariable("id") String id) {
        return orderService.queryGoodsDetail(id);
    }

    @GetMapping( "/queryCostDetail/{id}")
    public ResponseData<?> queryCostDetail(@PathVariable("id") String id) {
        return orderService.queryCostDetail(id);
    }

    @GetMapping( "/createSnowId")
    public ResponseData<?> createSnowId() {
        return orderServiceImpl.createSnowId();
    }

    @PostMapping("/queryCustomer")
    public ResponseData<?> queryCustomer() {
        return orderService.queryCustomer();
    }

    @PostMapping("/queryGoods")
    public ResponseData<?> queryGoods() {
        return orderService.queryGoods();
    }

    @PostMapping("/saveAddGoods")
    public ResponseData<?> saveAddGoods(@RequestBody List<NormalOrderDTO> normalOrderDTOS) {
        return orderService.addGoods(normalOrderDTOS);
    }

    @GetMapping( "/queryGoods/{id}")
    public ResponseData<?> queryGoods(@PathVariable("id") String id) {
        return orderService.queryGoods2(id);
    }

    @PostMapping("/createOrder")
    public ResponseData<?> createOrder(@RequestBody NormalOrderDTO normalOrderDTO) throws ParseException {
        return orderService.createOrder(normalOrderDTO);
    }

    @PostMapping("/scheduling")
    public ResponseData<?> scheduling(@RequestBody NormalOrderDTO normalOrderDTO) {
        return orderService.scheduling(normalOrderDTO);
    }

    @PostMapping("/combinedOrder")
    public ResponseData<?> combinedOrder(@RequestBody List<NormalOrderDTO> normalOrderDTOS) throws ParseException {
        return orderService.combinedOrder(normalOrderDTOS);
    }

    @PostMapping("/splitOrder")
    public ResponseData<?> splitOrder(@RequestBody NormalOrderDTO normalOrderDTO) {
        return orderService.splitOrder(normalOrderDTO);
    }

    @PostMapping("/cancelOrder")
    public ResponseData<?> cancelOrder(@RequestBody NormalOrderDTO normalOrderDTO) {
        return orderService.cancelOrder(normalOrderDTO);
    }

    @PostMapping("/batchCancelOrder")
    public ResponseData<?> batchCancelOrder(@RequestBody List<NormalOrderDTO> normalOrderDTOS) {
        return orderService.batchCancelOrder(normalOrderDTOS);
    }

    @GetMapping("/export")
    public ResponseData<?> exportYiData(HttpServletResponse response){
        return orderService.exportYiData(response);
    }
}
